package com.learn.thread;

import java.util.Arrays;
import java.util.List;

/**
 * 并行执行示例
 * @author:         MI
 * @email:          448341911@qq.com
 * @createTime:     2025/2/27 14:52
 * @updateUser:     MI
 * @updateTime:     2025/2/27 14:52
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
public class ParallelExample {


    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);

        // 并行处理：利用多线程加速计算
        numbers.parallelStream()
                .forEach(n -> {
                    int square = n * n;
                    System.out.println(Thread.currentThread().getName() + ": " + square);
                });
    }
}
